/*
 * Copyright (c) 2017 Qunar.com. All Rights Reserved.
 */
package com.guoyu.project.web.api;

import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.common.collect.Maps;
import com.guoyu.project.common.pagination.Pagination;
import com.guoyu.project.common.web.APIResponse;
import com.guoyu.project.model.Article;
import com.guoyu.project.model.enums.ArticleType;
import com.guoyu.project.service.ArticleService;
import com.guoyu.project.web.admin.NewsController;

/**
 * @author: libo Date: 17-2-13 Time: 下午1:20
 * @version: \$Id$
 */
@Controller
@RequestMapping("api/result")
public class ResultApiController {

    private final static Logger logger = LoggerFactory.getLogger(NewsController.class);

    @Resource
    private ArticleService articleService;

    /**
     * 典型案例接口
     *
     * @return
     */
    @RequestMapping("list")
    @ResponseBody
    public APIResponse list(@RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "10") int limit,
            @RequestParam(defaultValue = "REFORM") String type) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("majorType", ArticleType.RESULT);
        params.put("minorType", type);
        Pagination<Article> pagination = articleService.queryArticles(offset, limit, params);
        return APIResponse.returnSuccess(pagination);
    }
}
